/**
 * This file is loaded via the <script> tag in the index.html file and will
 * be executed in the renderer process for that window. No Node.js APIs are
 * available in this process because `nodeIntegration` is turned off and
 * `contextIsolation` is turned on. Use the contextBridge API in `preload.js`
 * to expose Node.js functionality from the main process.
 */
let {
	ipcRenderer
} = require("electron");

//const sort = [14,32,21,7,4,17,28,45,6,39,35,8,36,3,46,0,22,31,41,24,25,38,34,13,1,18,19,20,43,27,2,15,33,42,11,12,37,5,40,23,44,10,30,16,29,26,9];

ipcRenderer.on("data", (e, data) => {
	console.log("data", e, data)
	show(data);
});

function show(data) {
	/*let day = (new Date() - new Date(2024, 1, 1)) / (1000*3600*24);
	day = (~~day) % data.length;
	index = sort[day];*/
	for (const [id, name, word] of data.dataset) {
		if (name == data.select) {
			words.innerHTML = word;
			person.innerHTML = name;
			if (name == "方哲宸")
				words.className = "fzc";
			console.log(word, person, word.match(/[a-zA-Z]/g), word.matchAll(/[a-zA-Z]/g))
			
			const letterCount = word.match(/[a-zA-Z]/g)?.length || 0;
			console.log(letterCount)
            if (letterCount >= 5){
                box.className = "horizon";
            }else{
                box.className = Math.random()<0.5? "vertical": "horizon";
            }
			
			break;
		}
	}
}